package com.gitee.elf.core.backpack

import com.gitee.elf.core.entity.EntityInstance
import com.gitee.elf.core.entity.EntityStatus
import org.bukkit.entity.Entity

class Backpack(val owner: Entity) {

    val positions = mutableListOf<Position>()

    fun getPositionById(id: Long): Position? {
        return positions.firstOrNull { it.id == id }
    }

    fun getActivePositions(): List<Position> {
        return positions.filter { it.instance.status == EntityStatus.ACTIVE }
    }

    fun getPositionByIndex(index: Int): Position? {
        return positions.getOrNull(index)
    }

    fun addPosition(instance: EntityInstance) {
        addPosition(Position(100, instance))
    }

    fun addPosition(position: Position) {
        positions.add(position)
    }

    class Position(val id: Long, val instance: EntityInstance)

}